using System;
using System.Collections.Generic;
using System.Text;
using System.Windows.Forms;
using System.IO;

namespace Lu62Viewer
{
    public class UIOperations
    {       
        public static string OpenFile(string _fileName)
        {              
            string res = string.Empty;            
            using (StreamReader reader = new StreamReader(_fileName, Encoding.UTF8))
            {
                res = reader.ReadToEnd();
            }
            return res;
        }

        public static int FillTree(TreeView _tvLuTree, string _lu62String, char _selectedTerminator, char _selectedSeparator, int _selectedSegmentNameLenght)
        {
            try
            {
                _tvLuTree.Nodes.Clear();
                _tvLuTree.BeginUpdate();
                MyRootNode root = new MyRootNode(_lu62String, _selectedTerminator, _selectedSeparator, _selectedSegmentNameLenght);
                _tvLuTree.Nodes.Add(root);
                root.Expand();
                return root.Nodes.Count;                
            }
            finally
            {
                _tvLuTree.EndUpdate();
            }
        }

        

        
    }
}